import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SellerInfoVO, SellerInfoForm, SellerInfoQuery } from '@/api/lingxing/sellerInfo/types';

/**
 * 查询领星亚马逊店铺列表
 * @param query
 * @returns {*}
 */

export const listSellerInfo = (query?: SellerInfoQuery): AxiosPromise<SellerInfoVO[]> => {
  return request({
    url: '/lingxing/sellerInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询领星亚马逊店铺详细
 * @param sid
 */
export const getSellerInfo = (sid: string | number): AxiosPromise<SellerInfoVO> => {
  return request({
    url: '/lingxing/sellerInfo/' + sid,
    method: 'get'
  });
};

/**
 * 新增领星亚马逊店铺
 * @param data
 */
export const addSellerInfo = (data: SellerInfoForm) => {
  return request({
    url: '/lingxing/sellerInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改领星亚马逊店铺
 * @param data
 */
export const updateSellerInfo = (data: SellerInfoForm) => {
  return request({
    url: '/lingxing/sellerInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除领星亚马逊店铺
 * @param sid
 */
export const delSellerInfo = (sid: string | number | Array<string | number>) => {
  return request({
    url: '/lingxing/sellerInfo/' + sid,
    method: 'delete'
  });
};

/**
 * 同步领星接口
 * @returns {*}
 */
export const syncData = (query?: SellerInfoQuery) => {
  return request({
    url: '/lingxing/sellerInfo/syncData',
    method: 'post',
    data: query
  });
};

export const getNewestUpdateTime = () => {
  return request({
    url: '/lingxing/sellerInfo/getNewestUpdateTime',
    method: 'get'
  });
};
